﻿<?php
class SessionBean extends BeanUtils {

	var $attributes = array(
		"codigo" 			=> array("name" => "usuCodigo",			"type" => "varchar", "data" => ""),
		"nome" 				=> array("name" => "usuNome", 			"type" => "varchar", "data" => ""),
		"usuario"			=> array("name" => "usuApelido", 		"type" => "varchar", "data" => ""),
		"email" 			=> array("name" => "usuEmail", 			"type" => "varchar", "data" => ""),
		"status" 			=> array("name" => "usuStatus", 		"type" => "varchar", "data" => ""),
		"pontosGincana" 	=> array("name" => "usuPontosGincana", 	"type" => "varchar", "data" => ""),
		"portalPreference" 	=> array("name" => "usuPortalPreference","type" => "varchar", "data" => ""),
		"fontPreference" 	=> array("name" => "usuFontPreference", "type" => "varchar", "data" => "")
	);
}
class SessionApp extends Kernel{

	function getUserSession(){
	
		//return '{ codigo : "2", nome : "Marcos Zinni", apelido : "Zinni", email : "_marcos.zinni@gmail.com", status : "normal", pontosGincana : "", portalPreference : "default", fontPreference : "11px" }';
		if ( $this->isUserSession() ){
			return '{ codigo : "2", nome : "' . $_SESSION["user"]->getAttribute("nome") . '", apelido : "Zinni", email : "_marcos.zinni@gmail.com", status : "normal", pontosGincana : "", portalPreference : "default", fontPreference : "11px" }';
		} else {
			return '{}';
		}

	}
	function setUserSession( $userSessionBean ){
		$_SESSION["user"] = $userSessionBean;
	}
	function isUserSession(){
		return session_is_registered ( "user" );
	}
	function destroy(){
		session_destroy();
	}
	function SessionApp(){
		if ( !$this->isUserSession() ){
			session_start();
		}
	}

}
$SessionApp = new SessionApp();
?>
